﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class SalaryRuleItemsControllerBase : Controller{
	public SalaryRuleItemsControllerBase()
		: base()
	{
	}
	private static SalaryRuleItemsDAO _Service; 
	public static SalaryRuleItemsDAO Service{
		get{
			if(_Service==null)
				_Service = new SalaryRuleItemsDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public SalaryRuleItemsEntity MapDataRowToObject(DataRow row){
		SalaryRuleItemsEntity o = new SalaryRuleItemsEntity();
		 o.RuleContent=Convert.ToString(row["RuleContent"]);
		 if(!row.IsNull("CalculationType"))
			o.CalculationType=ConvertByte(row["CalculationType"]);
		 if(!row.IsNull("CalculationIndex"))
			o.CalculationIndex=ConvertInt(row["CalculationIndex"]);
		 if(!row.IsNull("SalaryFieldId"))
			o.SalaryFieldId=(Int32)(row["SalaryFieldId"]);
		 if(!row.IsNull("SalaryRuleId"))
			o.SalaryRuleId=(Int32)(row["SalaryRuleId"]);
		 if(!row.IsNull("SalaryRuleItemId"))
		    o.SalaryRuleItemId=(Int32)(row["SalaryRuleItemId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(SalaryRuleItemsEntity o,DataRow row){
		row["RuleContent"]=o.RuleContent;
		row["CalculationType"]=o.CalculationType;
		row["CalculationIndex"]=o.CalculationIndex;
		row["SalaryFieldId"]=o.SalaryFieldId;
		row["SalaryRuleId"]=o.SalaryRuleId;
		row["SalaryRuleItemId"]=o.SalaryRuleItemId;
    }
}
}
